import request from '@/utils/request'

export default {
  getRoleList(searchModel) {
    return request({
      url: '/role/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        roleName: searchModel.roleName,
      }
    })
  },
  addRole(roleForm) {
    return request({
      url: '/role/add',
      method: 'post',
      data: roleForm
    })
  },
  getRoleById(id) {
    return request({
      url: `/role/getRoleById/${id}`,
      method: 'get'
    })
  },
  updateRole(roleForm) {
    return request({
      url: '/role/update',
      method: 'post',
      data: roleForm
    })
  },
  saveRole(RoleForm) {
    if (RoleForm.roleId == null || RoleForm.roleId === undefined) {
      return this.addRole(RoleForm);
    } else {
      return this.updateRole(RoleForm);
    }
  },
  deleteRole(id) {
    return request({
      url: `/role/delete/${id}`,
      method: 'delete'
    })
  },
  getAllRole() {
    return request({
      url: '/role/getAllRole',
      method: 'get'
    })
  }
}
